Skip to content

Locate suppressions at their comment's # in pyrefly coverage#4030

Closed
jorenham wants to merge 1 commit into
facebook:mainfrom
jorenham:gh-4022
Closed

Locate suppressions at their comment's # in pyrefly coverage#4030
jorenham wants to merge 1 commit into
facebook:mainfrom
jorenham:gh-4022

Conversation

@jorenham

@jorenham jorenham commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

Suppression now records the string-aware comment offset already known at parse time, so pyrefly coverage report no longer points a suppression at a # inside a string literal.

Fixes #4022

Test Plan

Regression tests added

@github-actions

This comment has been minimized.

@jorenham

jorenham commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator Author

rebased onto main to resolve the merge conflicts

@github-actions github-actions Bot added the size/m label Jul 8, 2026
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@NathanTempest NathanTempest left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great fix as always @jorenham, LGTM for import.

Recording the string-aware comment_offset at parse time (where the triple-quote state is already tracked) is the right fix, and routing coverage through module.ignore() + range_to_location is a good cleanup that also reuses the canonical parse instead of re-parsing. Bonus: dropping the old line.find('#') removes a latent byte-vs-display column bug for multibyte lines too.

@meta-codesync

meta-codesync Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

@NathanTempest has imported this pull request. If you are a Meta employee, you can view this in D111306424.

@stroxler stroxler left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review automatically exported from Phabricator review in Meta.

@meta-codesync meta-codesync Bot closed this in 5b8f0d4 Jul 10, 2026
@meta-codesync meta-codesync Bot added the Merged label Jul 10, 2026
@meta-codesync

meta-codesync Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

@NathanTempest merged this pull request in 5b8f0d4.

@jorenham
jorenham deleted the gh-4022 branch July 10, 2026 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pyrefly coverage report locates suppressions at the first # on the line

3 participants